Trim event title to a maximum length in grouper#574
Conversation
| /** | ||
| * Trim title before hashing so hash and stored title stay consistent | ||
| */ | ||
| this.dataFilter.trimEventTitle(task.payload); |
There was a problem hiding this comment.
we already call this.dataFilter.processEvent(task.payload); , lets put this logic in there
There was a problem hiding this comment.
Pull request overview
This PR adds event-title trimming in the Grouper worker pipeline to cap excessively long titles (keeping hashing and stored payload consistent) and adds a regression test to validate the trimming behavior.
Changes:
- Add
DataFilter.trimEventTitle()to trimevent.titleto 1000 characters (plus an ellipsis when trimmed). - Invoke title trimming during
GrouperWorker.handleInternal()before unique-hash calculation. - Add a unit test ensuring long titles are trimmed before persisting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| workers/grouper/tests/index.test.ts | Adds coverage asserting long titles are truncated and end with an ellipsis. |
| workers/grouper/src/index.ts | Calls title trimming prior to computing the event’s unique hash (and affects downstream grouping/saving). |
| workers/grouper/src/data-filter.ts | Introduces title-trimming logic in DataFilter using the shared rightTrim() helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| this.dataFilter.processEvent(task.payload); | ||
|
|
||
| this.logger.info(`[handle] project=${task.projectId} catcher=${task.catcherType} title="${task.payload.title}" payloadSize=${taskPayloadSize}b backtraceFrames=${task.payload.backtrace?.length ?? 0}`); |
There was a problem hiding this comment.
why this log is needed? It will be printed for every event
| * @param event - event to process | ||
| */ | ||
| public processEvent(event: EventData<EventAddons>): void { | ||
| this.trimEventTitle(event); |
There was a problem hiding this comment.
Now we sanitize only title, but long strings (as well as very deep objects, long arrays) can be included in other fields:
- title
- context
- addends
- backtrace[].arguments
- breadcrumbs[].message
- breadcrumbs[].data
- breadcrumbs[].message
I'd suggest to add the Sanitizer utility like we have in Hawk JavaScript. And use it here in DataFilter.
Trims event title to 1000 chars